package com.sgb.knowledgeshare.viewmodel;

import androidx.lifecycle.ViewModel;

import com.sgb.knowledgeshare.ShareConfig;
import com.sgb.knowledgeshare.entity.FollowListEntity;
import com.sgb.knowledgeshare.view.activity.ShareUserAttentionActivity;
import com.swgk.core.base.api.ICallBack;
import com.swgk.core.base.model.entity.BaseEntity;
import com.swgk.core.util.MToast;
import java.util.HashMap;
import java.util.Map;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;

/**
 * Created by fq on 2020/9/10 0010
 * Description：分享-点赞model
 * */
public class ShareUserAttentionModel  extends ViewModel {

    ShareUserAttentionActivity activity;
    public void setActivity(ShareUserAttentionActivity shareUserAttentionActivity) {
        activity = shareUserAttentionActivity;
    }

//    当前用户的关注列表
    public void getFollowList(int page, String userid) {
        Map map = new HashMap();
        map.put("pageNum",page);
        map.put("pageSize",20);
        map.put("userNo",userid);
       ShareConfig.getInstance().getApi().getFollowList(map).enqueue(new ICallBack<BaseEntity<FollowListEntity>>() {
           @Override
           public void onSuccess(BaseEntity<FollowListEntity> data) {
               if (data.getData() == null) {
                   return;
               }
               if (data.getState().equals(ShareConfig.RESPONSE_OK)) {
                   activity.setFollowList(data.getData());
               } else {
                   MToast.showToast(activity.getActivity(), data.getMsg());
               }
           }
       });

    }

//    关注、取消关注
    public void getFens(String userNo) {
        Map map = new HashMap();
        map.put("userNo",userNo );
       ShareConfig.getInstance().getApi().getfens(map).enqueue(new ICallBack<BaseEntity>() {
           @Override
           public void onSuccess(BaseEntity data) {
               if (data.getData() == null) {
                   return;
               }
               if (data.getState().equals(ShareConfig.RESPONSE_OK)) {
                   activity.setFens();
               } else {
                   MToast.showToast(activity.getActivity(), data.getMsg());
               }
           }
       });
    }


}
